import java.io.DataInputStream;
import java.io.DataOutputStream;
import java.io.IOException;
import java.net.ServerSocket;
import java.net.Socket;
import java.net.UnknownHostException;
import java.util.Scanner;


public class Cliente {
	
	private static String host = "localhost";
	
	private static int port = 5000;
	/**
	 * @param args
	 */
	public static void main(String[] args) {

		
		Socket cliSocket;
		try {
			cliSocket = new Socket(host, port);
			DataOutputStream dos = new DataOutputStream(cliSocket.getOutputStream());
			DataInputStream dis = new DataInputStream(cliSocket.getInputStream());
			
			Scanner sc = new Scanner(System.in);
			String line;
			do {			
				System.out.print("Mensaje: ");
				line = sc.nextLine();			
				dos.writeUTF(line);
				
				line = dis.readUTF();
				System.out.println(">> "+line);
				
			} while (!line.equals("END"));
						
			cliSocket.close();			
		} catch (UnknownHostException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} catch (IOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		

	}

}
